package com.tjsinfo.tjsoa.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;



/**
 * 获取SESSION中的用户
 * @author wangxiaowei
 *
 */
public class SessionUser {
	/**
	 * 返回用户对象
	 * @param Session
	 * @return
	 */
	public static User getUser(HttpSession session)
	{
		User user = (User) session.getAttribute("user");
		return user;
	}
	/**
	 * 返回用户ID
	 * @param Session
	 * @return
	 */
	public static Integer getUserId(HttpSession session)
	{
		User user = getUser(session);
		return user.getUser_id();
	}
	/**
	 * 返回用户对象
	 * @param request
	 * @return
	 */
	public static User getUser(HttpServletRequest request)
	{
		return  getUser(request.getSession());
	}
	/**
	 * 返回用户id
	 * @param request
	 * @return
	 */
	public static Integer getUserId(HttpServletRequest request)
	{
		return  getUserId(request.getSession());
	}
}
